package yunwo.cn.yzstation.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.base.BasicAdapter;
import yunwo.cn.yzstation.bean.InventoryBean;

/**
 * Created by lao on 2017/9/14.
 */

public class IvetoryLvadatoer extends BasicAdapter<InventoryBean.DataBean.ListBean> {
    public IvetoryLvadatoer(Context mctx) {
        super(mctx);
    }

    @Override
    protected int setItemLayout() {
        return R.layout.item_iventory;
    }

    @Override
    protected void bindData(View convertView, InventoryBean.DataBean.ListBean data, int position) {
        TextView consignor = get(convertView, R.id.consignor);
        TextView consignorphone = get(convertView, R.id.consignorphone);
        TextView consignee = get(convertView, R.id.consignee);
        TextView consigneephone = get(convertView, R.id.consigneephone);
        TextView beginOrganName = get(convertView, R.id.beginOrganName);
        TextView endOrganName = get(convertView, R.id.endOrganName);
        TextView trackingNumber = get(convertView, R.id.trackingNumber);
        TextView state = get(convertView, R.id.state);
        if (data.getConsignorName().equals("") && data.getConsignorPhone().equals("")) {
            consignor.setVisibility(View.GONE);
            consignorphone.setText("暂未填写发货人信息");
        }else {
            consignor.setText(data.getConsignorName());
            consignorphone.setText(data.getConsignorPhone());
        }

        consignee.setText(data.getConsigneeName());
        consigneephone.setText(data.getConsigneePhone());
        beginOrganName.setText(data.getBeginOrganName());
        endOrganName.setText(data.getEndOrganName());
        trackingNumber.setText("运单号："+data.getTrackingNumber());
        switch (data.getTrackingStatus()) {

            case 1:
                state.setText("派单中");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 2:
                state.setText("待提货");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 3:
                state.setText("拉包中");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 4:
                state.setText("待发车");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 5:
                state.setText("运输中");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 6:
                state.setText("待配送");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 7:
                state.setText("待签收");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;
            case 8:
                state.setText("已签收");
                state.setBackgroundResource(R.drawable.icon_have_in_hand);
                break;
            case 9:
                state.setText("已取消");
                state.setBackgroundResource(R.drawable.list_icon_end);
                break;

        }
    }
}
